package o;

import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.RectF;
import android.graphics.Shader.TileMode;
import android.util.Log;

public class evb {
    public static Bitmap ˏ(Bitmap bitmap, int i, int i2) {
        if (bitmap == null || bitmap.getWidth() == 0 || bitmap.getHeight() == 0) {
            Log.e("HwStaticBlurEngine", "blur: input bitmap is null or bitmap size is 0");
            return null;
        } else if (i <= 0 || i2 <= 0) {
            Log.e("HwStaticBlurEngine", "blur: blur radius and downscale must > 0");
            return null;
        } else {
            int i3 = (int) (((float) i) / ((float) i2));
            if (i3 != 0) {
                return ˋ(ˏ(bitmap, i2), i3);
            }
            Log.e("HwStaticBlurEngine", "blur: blur radius downscale must < radius");
            return null;
        }
    }

    private static Bitmap ˏ(Bitmap bitmap, int i) {
        int max = Math.max(1, bitmap.getWidth() / i);
        int max2 = Math.max(1, bitmap.getHeight() / i);
        Bitmap createBitmap = Bitmap.createBitmap(max, max2, Config.ARGB_4444);
        Canvas canvas = new Canvas(createBitmap);
        RectF rectF = new RectF(0.0f, 0.0f, (float) max, (float) max2);
        Paint paint = new Paint();
        paint.setShader(ˏ(bitmap, createBitmap));
        canvas.drawRect(rectF, paint);
        return createBitmap;
    }

    private static BitmapShader ˏ(Bitmap bitmap, Bitmap bitmap2) {
        float width = ((float) bitmap2.getWidth()) / ((float) bitmap.getWidth());
        float height = ((float) bitmap2.getHeight()) / ((float) bitmap.getHeight());
        Matrix matrix = new Matrix();
        matrix.postScale(width, height);
        TileMode tileMode = TileMode.CLAMP;
        BitmapShader bitmapShader = new BitmapShader(bitmap, tileMode, tileMode);
        bitmapShader.setLocalMatrix(matrix);
        return bitmapShader;
    }

    private static Bitmap ˋ(Bitmap bitmap, int i) {
        Bitmap createBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_4444);
        eve.ˎ().ˎ(bitmap, createBitmap, i);
        return createBitmap;
    }
}
